﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using PPAP.BO;

namespace PPAP.Web.Part
{
    public partial class SampleCardPrint : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    DataSet ds = new SamplecardBO().GetPrint(Request.QueryString["id"].ToString());
                    if (ds.Tables[0].Rows.Count>0)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        lblSampleCard.Text = dr["samplecardno"].ToString();
                        lblSampleVersion.Text = dr["version"].ToString();
                        lblPPAR.Text = dr["pparno"].ToString();
                        lblPPARVersion.Text = dr["pparversion"].ToString();
                        lblStatus.Text = Status(dr["status"].ToString());
                        lblSupplierName.Text = dr["suppliername"].ToString();
                        lblBDNTRevisionNo.Text = dr["bdntrevisionno"].ToString();
                        SupplierNo.Text = dr["suppliercode"].ToString();
                        BDNTRevisionStatus.Text = dr["bdntrevisionstatus"].ToString();
                        SamplingReason.Text = dr["reasonforsampling"].ToString();
                        lblModificationScope.Text = dr["modificationscope"].ToString();
                        lblDepartment.Text = dr["testitemname"].ToString();
                        lblHWVersion.Text = dr["ecuhwversionno"].ToString();
                        lblSWVersion.Text = dr["ecuswversionno"].ToString();
                        lblQualityMaganment.Text = dr["quanlitymanager"].ToString();
                        lblTeName.Text = dr["deptrep"].ToString();
                        lblPhone.Text = dr["mo1"].ToString();
                        lblTelePhone.Text = dr["mo2"].ToString();
                        lblDate.Text = dr["starttime"].ToString();
                        lblDate0.Text = dr["starttime"].ToString();
                        cbG.Checked = dr["result"].ToString() == "G" ? true : false;
                        cbR.Checked = dr["result"].ToString() == "R" ? true : false;
                        cbY.Checked = dr["result"].ToString()== "Y" ? true : false;
                    }
                }
            }
        }

        public string Status(string status)
        {
            string font = "";
            switch (status)
            {
                case "0":
                    font = "Created";
                    break;
                case "1":
                    font = "Circulating";
                    break;
                case "2":
                    font = "Circulating(<font color='red'>Reject</font>)";
                    break;
                default:
                    font = "Decided";
                    break;
            }
            return font;

        }
    }
}